﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FineUI;

namespace lcmyjobs.Web.users
{
    public partial class user_reward : BasePage
    {
        lcmyjobs.BLL.user_basic bub = new BLL.user_basic();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.Title = string.Format("个人管理中心—悬赏&bull;猎头服务：悬赏求职   {0}", Application["webname"].ToString());
                if (Session["user_id"] != null)
                {
                    int id = int.Parse(Session["user_id"].ToString());
                    this.lblName.Text = Session["user_name"].ToString();
                    getreward(id);

                }
                else
                {
                    Response.Redirect("userlogin.html");
                }
            }

        }
        protected void getreward(int id)
        {
            float r = 0;
            r = bub.getreward(id);
            hfvalue.Value = r.ToString();
            if (r == 0)
            {
                lblstatus.Text = "你还没有申请悬赏求职";
                this.lblhint.Text = "您快捷找到：适合的、满意的、同您的职业愿景吻合的工作，建议您选择悬赏求职，您将有机会借助猎手人脉资源关系，及我就业网悬赏服务，被推荐适合的工作<br />";
            }
            else
            {
                lblstatus.Text = "你已申请悬赏求职 金额：" + r.ToString()+"元";
                this.lblhint.Text = "您选择悬赏求职，借助猎手人脉资源关系及我就业网悬赏服务，我们会尽快为您推荐适合的工作！<br />";
            }

        }

        protected void btndel_Click(object sender, EventArgs e)
        {
            if (Session["user_id"] != null)
            {
                int id = int.Parse(Session["user_id"].ToString());
                bub.deletereward(id);
                getreward(id);
            }
            else
            {
                Response.Redirect("userlogin.html");
            }
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (Session["user_id"] != null)
                {
                    int id = int.Parse(Session["user_id"].ToString());
                    try
                    {
                        float i = float.Parse(txtadd.Text);
                        if (i != 0f)
                        {
                            int r = bub.updatereward(id, i);
                            if (r == 0)
                            {
                                Maticsoft.Common.MessageBox.Show(this, "更新失败！");
                            }
                        }
                        getreward(id);
                    }
                    catch (Exception ex)
                    {
                        Maticsoft.Common.MessageBox.Show(this, "更新失败！");
                    }
                }
                else
                {
                    Response.Redirect("userlogin.html");
                }
            }
        }

        protected void btnupdate_Click(object sender, EventArgs e)
        {
            if (Session["user_id"] != null)
            {
                int id = int.Parse(Session["user_id"].ToString());
                try
                {
                    float i = float.Parse(txtupdate.Text);
                    if (i != 0f)
                    {
                        int r = bub.updatereward(id, i);
                        if (r == 0)
                        {
                            Maticsoft.Common.MessageBox.Show(this, "更新失败！");

                        }
                    }

                    getreward(id);
                }
                catch (Exception ex)
                {

                    Maticsoft.Common.MessageBox.Show(this, "更新失败！");
                }
            }
            else
            {
                Response.Redirect("userlogin.html");
            }


        }

        protected void btn_why_Click(object sender, EventArgs e)
        {

            //Alert alert = new Alert();
            string msg = "<div style='width:250px;text-indent:2em;line-height:20px;'><p style='padding-Bottom:5px; >  悬赏求职：更准确、更快捷。</p>";
            msg += "<p style='padding-Bottom:5px; >  更准确----提供专业的人才选择工具，帮助您深度甄选工作。 基于人才胜任素质的评测工具辅助单位招聘。颠覆被动“等待”招聘的传统方式。</p>";
            msg += "<p style='padding-Bottom:5px; >  更快捷----发挥社会力量，动员群众，借助猎手人脉资源关系，让您的悬赏信息迅速覆盖目标群体，快捷找到合适工作。</p></div>";

            Alert.Show(msg);
        }
    }
}